home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.io.DataInputStream;
-
- public class CListBoxResponse extends CDisplayResponse {
- private int m_nFlags = 17;
- private Color m_rgbFg = new Color(0, 0, 0);
- private Color m_rgbBg = new Color(255, 255, 255);
- private String m_strFillWith = "";
- private String m_strSelect = "";
- private String m_strDelimiter = "";
- private char m_nVariableID = 0;
- private CFontObject m_clsFontObject = new CFontObject();
- private String m_strList = "";
- private CComboBox m_ComboBox = null;
- private CListBox m_ListBox = null;
-
- boolean LoadFromFile(DataInputStream var1) {
- this.m_nVariableID = (char)FileLoad.ReadCPlusInt(var1);
- this.m_nFlags = FileLoad.ReadCPlusInt(var1);
- this.m_rgbFg = FileLoad.ReadColor(var1);
- this.m_rgbBg = FileLoad.ReadColor(var1);
- this.m_strFillWith = FileLoad.ReadCString(var1);
- this.m_strSelect = FileLoad.ReadCString(var1);
- this.m_strDelimiter = FileLoad.ReadCString(var1);
- this.m_clsFontObject.LoadFromFile(var1);
- return super.LoadFromFile(var1);
- }
-
- public void DoEntryResponse() {
- this.DoResponse(0);
- }
-
- public CListBoxResponse() {
- super(45);
- }
-
- CResponseReturn DoResponse(int var1) {
- CResponseReturn var2 = new CResponseReturn(0, var1);
- if (this.m_nVariableID != 0) {
- CVariable var3 = Utils.SearchAllVariables(this.m_nVariableID);
- if (var3 != null) {
- String var4 = "";
- if (this.m_ListBox != null && (this.m_nFlags & 1) != 0) {
- if ((this.m_nFlags & 8) != 0) {
- String var5 = this.m_strDelimiter.length() > 0 ? this.m_strDelimiter : "\r\n";
-
- for(int var7 = 0; var7 < this.m_ListBox.GetSelCount(); ++var7) {
- String var6 = this.m_ListBox.GetSel(var7);
- if (var4.length() > 0) {
- var4 = var4 + var5;
- }
-
- var4 = var4 + var6;
- }
- } else {
- var4 = this.m_ListBox.GetSel();
- }
- } else if (this.m_ComboBox != null && (this.m_nFlags & 2) != 0) {
- var4 = this.m_ComboBox.GetSel();
- }
-
- System.out.println("Selection = " + var4);
- if (var4.length() > 0) {
- switch (var3.GetType()) {
- case 256:
- var3.SetValue(var4);
- break;
- case 512:
- try {
- var3.SetValue(Double.valueOf(var4));
- } catch (NumberFormatException var9) {
- var3.SetValue((double)0.0F);
- }
- break;
- case 1024:
- try {
- var3.SetValue(Long.valueOf(var4));
- } catch (NumberFormatException var8) {
- var3.SetValue(0L);
- }
- }
- } else {
- var3.Reset();
- }
- }
- }
-
- return var2;
- }
-
- public boolean OnMouseClick(int var1, int var2, Point var3, int var4, CRect var5) {
- if (var4 == 7) {
- if ((this.m_nFlags & 1) != 0 && this.m_ListBox != null) {
- if (var1 == 2022 && ((CDisplayResponse)this).HitTest(var3)) {
- this.m_ListBox.ProcessMouseDown(var3);
- } else if (var1 == 2023 && this.m_ListBox.HasFocus()) {
- this.m_ListBox.ProcessMouseUp(var3);
- }
- } else if ((this.m_nFlags & 2) != 0 && this.m_ComboBox != null) {
- if (var1 != 2022 || !((CDisplayResponse)this).HitTest(var3) && !this.m_ComboBox.ListVisible()) {
- if (var1 == 2023 && this.m_ComboBox.HasFocus()) {
- this.m_ComboBox.ProcessMouseUp(var3);
- }
- } else {
- this.m_ComboBox.ProcessMouseDown(var3);
- }
- }
- }
-
- return false;
- }
-
- public boolean SetResponse() {
- if (!((CDisplayResponse)this).GetActualRect().isEmpty()) {
- boolean var1 = false;
- CRect var2 = new CRect(((CDisplayResponse)this).GetActualRect());
- if ((this.m_nFlags & 1) != 0) {
- if (this.m_ListBox == null) {
- this.m_ListBox = new CListBox(this.m_nFlags, ((CDisplayResponse)this).GetActualRect());
- this.m_ListBox.SetFont(this.m_clsFontObject.GetFont());
- this.m_ListBox.SetBgColour(this.m_rgbBg);
- this.m_ListBox.SetFgColour(this.m_rgbFg);
- } else if (!((Rectangle)var2).equals(((CDisplayResponse)this).GetDrawRect())) {
- this.m_ListBox.SetRect(var2);
- }
-
- String var5 = Utils.InsertVariablesInString(this.m_strFillWith);
- if (var5.length() > 0 && !this.m_strList.equals(var5)) {
- this.m_strList = var5;
- this.m_ListBox.FillListBox(var5, this.m_strDelimiter);
- var1 = true;
- }
-
- String var6 = Utils.InsertVariablesInString(this.m_strSelect);
- if (var6.length() > 0) {
- this.m_ListBox.SetSelections(var6, this.m_strDelimiter);
- var1 = true;
- }
- } else if ((this.m_nFlags & 2) != 0) {
- if (this.m_ComboBox == null) {
- this.m_ComboBox = new CComboBox(this.m_nFlags, ((CDisplayResponse)this).GetActualRect());
- this.m_ComboBox.SetFont(this.m_clsFontObject.GetFont());
- this.m_ComboBox.SetBgColour(this.m_rgbBg);
- this.m_ComboBox.SetFgColour(this.m_rgbFg);
- } else if (!((Rectangle)var2).equals(((CDisplayResponse)this).GetDrawRect())) {
- this.m_ComboBox.SetRect(var2);
- }
-
- String var3 = Utils.InsertVariablesInString(this.m_strFillWith);
- if (var3.length() > 0 && !this.m_strList.equals(var3)) {
- this.m_strList = var3;
- this.m_ComboBox.FillListBox(var3, this.m_strDelimiter);
- }
-
- String var4 = Utils.InsertVariablesInString(this.m_strSelect);
- if (!this.m_ComboBox.SelectionValid() || var4.length() > 0 && !var4.equals(this.m_ComboBox.GetSel())) {
- this.m_ComboBox.SetSelections(var4, this.m_strDelimiter);
- var1 = true;
- }
- }
-
- if (!((Rectangle)var2).equals(((CDisplayResponse)this).GetDrawRect())) {
- if (!((CDisplayResponse)this).GetDrawRect().isEmpty()) {
- Globals.thePresView.InvalidateOffScreenRect(((CDisplayResponse)this).GetDrawRect());
- }
-
- ((CDisplayResponse)this).SetDrawRect(var2);
- var1 = true;
- }
-
- Globals.thePresView.AddDrawObject((CIconObject)this, 1024, var1);
- }
-
- return true;
- }
-
- public boolean OnMouseMove(int var1, Point var2, int var3, CRect var4) {
- if (var3 == 7) {
- if (this.m_ListBox != null && (this.m_nFlags & 1) != 0 && (this.m_nFlags & 8) == 0) {
- if (this.m_ListBox.HasFocus()) {
- this.m_ListBox.ProcessMouseMove(var2);
- }
- } else if (this.m_ComboBox != null && (this.m_nFlags & 2) != 0 && this.m_ComboBox.ListVisible()) {
- this.m_ComboBox.ProcessMouseMove(var2);
- }
- }
-
- return false;
- }
-
- public void DrawObject(Graphics var1, int var2, CRect var3) {
- if (this.m_ListBox != null) {
- this.m_ListBox.DrawControl(var1, var3);
- } else {
- if (this.m_ComboBox != null) {
- this.m_ComboBox.DrawControl(var1, var3);
- }
-
- }
- }
- }
-